Jam - A Smooth Extension of Java with Mixins
نویسندگان
چکیده
In this paper we present Jam, an extension of the Java language supporting mixins, that is, parametric heir classes. A mixin declaration in Jam is similar to a Java heir class declaration, except that it does not extend a fixed parent class, but simply specifies the set of fields and methods a generic parent should provide. In this way, the same mixin can be instantiated on many parent classes, producing different heirs, thus avoiding code duplication and largely improving modularity and reuse. Moreover, as happens for classes and interfaces, mixin names are reference types, and all the classes obtained instantiating the same mixin are considered subtypes of the corresponding type, hence can be handled in a uniform way through the common interface. This possibility allows a programming style where different ingredients are “mixed” together in defining a class; this paradigm is somehow similar to that based on multiple inheritance, but avoids the associated complications. The language has been designed with the main objective in mind to obtain, rather than a new theoretical language, a working and smooth extension of Java. That means, on the design side, that we have faced the challenging problem of integrating the Java overall principles and complex type system with this new notion; on the implementation side, that we have developed a Jam to Java translator which makes Jam sources executable on every Java Virtual Machine.
منابع مشابه
A Programmer's Reduction Semantics for Classes and Mixins
While class-based object-oriented programming languages provide a flexible mechanism for re-using and managing related pieces of code, they typically lack linguistic facilities for specifying a uniform extension of many classes with one set of fields and methods. As a result, programmers are unable to express certain abstractions over classes. In this paper we develop a model of class-to-class ...
متن کاملScheme with Classes, Mixins, and Traits
The Scheme language report advocates language design as the composition of a small set of orthogonal constructs, instead of a large accumulation of features. In this paper, we demonstrate how such a design scales with the addition of a class system to Scheme. Specifically, the PLT Scheme class system is a collection of orthogonal linguistic constructs for creating classes in arbitrary lexical s...
متن کاملModular and Extensible Parser Implementation using Mixins (DRAFT)
This paper describes a method to construct highly modular and extensible recursive descent parser. This parser is used in an extensible Java preprocessor, EPP. EPP can be extended by adding plug-ins which extend Java syntax and add new language features. The EPP's parser consists of small mixins. A recursive descent parser class is constructed by composing these mixins. The syntax accepted by t...
متن کاملSafe Instantiation in Generic Java
This paper presents the “safe-instantiation principle” a new design principle for evaluating extensions of Java with support for generic types. We discuss the GJ and NextGen formulations of Generic Java and the implications of safe instantiation on both approaches. We then consider the implications of safe-instantiation for the addition of mixins to Java via generic types. Finally, we defend th...
متن کامل